/*
 * FileName: NewsDaoImpl.java
 *
 * Company: 
 * Copyright 2011-2012 (C) Ultrapower Software CO., LTD. All Rights Reserved.
 */
package com.jmeurope.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.jmeurope.dao.IbatisBaseDao;
import com.jmeurope.dao.NewsDao;
import com.jmeurope.model.News;

/**
 * <p>
 * Description: 
 * </p>
 *
 * @author wangwei  leo_java@163.com
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * Dec 27, 2011 7:16:24 PM          wangwei        1.0         To create
 * </p>
 *
 * @since 
 * @see     
 */
@SuppressWarnings("unchecked")
@Repository
public class NewsDaoImpl extends IbatisBaseDao implements NewsDao{

	@Override
	public void delete(Integer id) throws Exception {
		getSqlMapClientTemplate().getSqlMapClient().delete("deleteNewsById",id);
		
	}

	@Override
	public News find(Integer id) throws Exception {
		return (News)getSqlMapClientTemplate().getSqlMapClient().queryForObject("selectNewsById",id);
	}


	@Override
	public List<News> findAll() throws Exception {
		List<News> news = getSqlMapClientTemplate().getSqlMapClient().queryForList("getAllNews");
		return news;
	}

	@Override
	public Integer insert(News entity) throws Exception {
		// TODO Auto-generated method stub
		return (Integer)getSqlMapClientTemplate().getSqlMapClient().insert("insertNews",entity);
	}

	@Override
	public void update(News entity) throws Exception {
		getSqlMapClientTemplate().getSqlMapClient().update("updateNews", entity);
		
	}

	@Override
	public List<News> getNewsByStatus(Map map) throws Exception {
		return getSqlMapClientTemplate().getSqlMapClient().queryForList("getAllNewsByStatus",map);
	}

	@Override
	public List<News> getNewsByStattusAndUpdateDate(Map map) throws Exception {
		return getSqlMapClientTemplate().getSqlMapClient().queryForList("getNewsByDateAndStatus", map);
	}
	@Override
	public List<News> getNewsByStattusAndBussinessId(Map map) throws Exception {
		return getSqlMapClientTemplate().getSqlMapClient().queryForList("getNewsByStatusAndBussinessId",map);
	}

}
